package org.mysfit.ctp4j.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * 
 * @author long.gf
 *
 */

@Configuration
@EnableWebMvc
public class WebMvcConfig extends WebMvcConfigurationSupport {

	@Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("/**").addResourceLocations(
	            "classpath:/static/");
	    registry.addResourceHandler("swagger-ui.html").addResourceLocations(
	            "classpath:/META-INF/resources/");
	    registry.addResourceHandler("/webjars/**").addResourceLocations(
	            "classpath:/META-INF/resources/webjars/");
	    super.addResourceHandlers(registry);
    }

	@Override
	protected void addCorsMappings(CorsRegistry registry) {
		registry.addMapping("/v2/api-docs");
		super.addCorsMappings(registry);
	}
	
}
